package com.dl.mian.http;

import com.google.gson.Gson;

import java.util.HashMap;
import java.util.Map;

import okhttp3.MediaType;
import okhttp3.RequestBody;

public class ServerApiTool {

    private final Map<String, Object> map = new HashMap<>();

    public static ServerApiTool putPar(String key, Object value) {
        ServerApiTool serverApiTool = new ServerApiTool();
        serverApiTool.map.put(key, value);
        return serverApiTool;
    }

    public ServerApiTool putPara(String key, Object value) {
        this.map.put(key, value);
        return this;
    }

    public RequestBody finish() {
        return RequestBody.create(MediaType.parse("application/json"), new Gson().toJson(map));
    }
}
